package com.dream.keigezhushou.Activity.acty.personal;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.activity.BaseActivity;
import com.dream.keigezhushou.Activity.kege.acty.ChorusListActivity;
import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MyChorusActivity extends BaseActivity {

    @BindView(R.id.iv_return)
    ImageView ivReturn;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.chorus_list)
    ListView chorusList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_chorus);
        ButterKnife.bind(this);

        initView();
        initData();
    }

    //初始化界面
    protected void initView(){

        tvTitle.setText("我的合唱");
    }

    //初始化数据
    protected void initData(){

        ivReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //返回
                finish();
            }
        });

        //ListView创建适配器
        chorusList.setAdapter(new ChorusAdapter(this));
    }

    public class ChorusAdapter extends BaseAdapter {

        private Context mContext;
        int c = 20;
        public ChorusAdapter(Context context) {
            this.mContext = context;
        }

        @Override
        public int getCount() {
            return c;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ChorusViewHolder mHoler = null;
            if (convertView == null){

                convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_chorus_item,null);
                mHoler = new ChorusViewHolder();

                mHoler.rlAdd = (RelativeLayout)convertView.findViewById(R.id.rl_add_list) ;
                convertView.setTag(mHoler);
            }else {
                mHoler = (ChorusViewHolder)convertView.getTag();
            }


//            mHoler.rlAdd.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//
//                    Intent intent = new Intent(mContext, ChorusListActivity.class);
//                    startActivity(intent);
//                }
//            });
            return convertView;
        }

        class ChorusViewHolder{

            RelativeLayout rlAdd;
        }
    }
}
